#!/usr/bin/python
# plot_darklight.py

import math
import numpy
from matplotlib import use as useBackend
useBackend('Agg')
import matplotlib.pyplot as ppt


def cheat111():
    '''Cheat to clear the plot.'''
    ppt.subplot(311)
    ppt.plot([0,1],[1,2])
    ppt.subplot(131)
    ppt.plot([0,1],[1,2])
    ppt.subplot(111)


def plot(Mv_comp_vals, BMlist, Klist, type):
    '''Shows GM_darklight's results.'''
    cheat111()
    ppt.hold(True)
    BM = ppt.plot(Mv_comp_vals, numpy.log10(BMlist), ls='None', marker='.')
    K = ppt.plot(Mv_comp_vals, numpy.log10(Klist), ls='None', marker='.')
    ppt.legend([BM,K],['Binney & Merrifield (visible stars)', 'Kroupa (compact masses)'], loc=4)
    titularwords = 'Comparison of local mass and light, '+type
    filename = 'darklight_'+type+'.pdf'
    ppt.title(titularwords)
    ppt.xlabel('Magnitude')
    ppt.ylabel('Log10 stars per cubic parsec')
    ppt.savefig(filename)
